package org.dreamwork.sso.saml2.protocol;

/**
 * Created with IntelliJ IDEA.
 * User: seth.yang
 * Date: 13-8-17
 * Time: 上午2:25
 */
public enum SamlStatus {
    SUCCESSFUL {
        @Override
        public String getStatusCode () {
            return "urn:oasis:names:tc:SAML:2.0:status:Success";
        }
    },
/*
    VERSION_TOO_HIGH {
        @Override
        public String getStatusCode () {
            return "urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooHigh";
        }
    },
    VERSION_TOO_LOW {
        @Override
        public String getStatusCode () {
            return "urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooLow";
        }
    },
*/
    REQUEST_DENIED {
        @Override
        public String getStatusCode () {
            return "urn:oasis:names:tc:SAML:2.0:status:RequestDenied";
        }
    },
    REQUEST_UNSUPPORTED {
        @Override
        public String getStatusCode () {
            return "urn:oasis:names:tc:SAML:2.0:status:RequestUnsupported";
        }
    },
    PARTIAL_LOGOUT {
        @Override
        public String getStatusCode () {
            return "urn:oasis:names:tc:SAML:2.0:status:PartialLogout";
        }
    },
    UNKNOWN_PRINCIPAL {
        @Override
        public String getStatusCode () {
            return "urn:oasis:names:tc:SAML:2.0:status:UnknownPrincipal";
        }
    },
    INVALID_SIGNATURE {
        @Override
        public String getStatusCode () {
            return "urn:oasis:names:tc:SAML:2.0:status:InvalidSignature";
        }
    },
    REQUESTER {
        @Override
        public String getStatusCode () {
            return "urn:oasis:names:tc:SAML:2.0:status:Requester";
        }
    },
    RESPONDER {
        @Override
        public String getStatusCode () {
            return "urn:oasis:names:tc:SAML:2.0:status:Responder";
        }
    };

    public abstract String getStatusCode ();

    public static SamlStatus parse (String text) {
        for (SamlStatus status : values ()) {
            if (status.getStatusCode ().equalsIgnoreCase (text))
                return status;
        }
        return UNKNOWN_PRINCIPAL;
    }
}
